﻿using Sgr.Domain.Managers;
using System.Threading;
using System.Threading.Tasks;

namespace Sgr.DataCategories.Domain.DataCategoryItem
{
    /// <summary>
    /// 数据字典项领域服务接口
    /// </summary>
    public interface IDataCategoryItemManage : ITreeNodeManage<DataCategoryItem, long>
    {
        /// <summary>
        /// 创建新的数据字典项
        /// </summary>
        /// <param name="name">字典项名称</param>
        /// <param name="value">字典项值</param>
        /// <param name="remarks">备注</param>
        /// <param name="categoryTypeCode">字典分类编码</param>
        /// <param name="orderNumber">排序号</param>
        /// <param name="parentId">上级节点ID</param>
        /// <param name="isEditable">是否可编辑</param>
        /// <param name="cancellationToken">取消令牌</param>
        /// <returns>数据字典项</returns>
        Task<DataCategoryItem> CreateNewAsync(
            string name,
            string value,
            string? remarks,
            string categoryTypeCode,
            int orderNumber,
            bool isEditable = true,
            long? parentId = null,
            CancellationToken cancellationToken = default);

        /// <summary>
        /// 检查字典项值是否唯一
        /// </summary>
        /// <param name="value">字典项值</param>
        /// <param name="categoryTypeCode">字典分类编码</param>
        /// <param name="excludeId">需要排除的ID</param>
        /// <param name="cancellationToken">取消令牌</param>
        /// <returns>值是否唯一</returns>
        Task<bool> IsValueUniqueAsync(
            string value,
            string categoryTypeCode,
            long? excludeId = null,
            CancellationToken cancellationToken = default);
    }
}